#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
class Solution {
public:
    int longestOnes(vector<int>& nums, int k) {
        int left = 0;
        int right = 0;
        int n = 0;
        int max = k;
        int len = nums.size();
        while (right < len) {
            if (nums[right] == 0) {
                n++;
            }
            while (n > k) {
                if (nums[left] == 0) {
                    n--;
                }
                left++;
            }
            right++;
            if (max < right - left) {
                max = right - left;
            }
        }
        return max;
    }
};
int main()
{
    return 0;
}